<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<table id="video_table" lay-filter="video_table"></table>
	<script type="text/html" id="barDemo">
	<div class="layui-btn-container">
		<button class="layui-btn layui-btn-sm" lay-event="details">详情</button>
        <button class="layui-btn layui-btn-sm" lay-event="delete">删除</button>
  	</div>
</script>
	<script type="text/html" id="toolbarDemo">
	<div class="layui-btn-container">
		<button class="layui-btn layui-btn-sm" lay-event="xizeng">新增</button>
  	</div>
</script>

	<script type="text/javascript">
		layui.use('table', function() {
			var table = layui.table;
			table.render({
				elem : '#video_table',
				url : 'coursewarev/page1',
				title : "视频课件",
				id : 'idTest',
				toolbar : '#toolbarDemo',
				height:'full-160',
				cols : [ [ {
					field : 'kcname',
					title : '课程'
				},{
					field : 'filename',
					title : '文件名'
				}, {
					field : 'resourceprofile',
					title : '文件简介'
				}, {
					fixed : 'right',
					title : '功能',
					align : 'center',
					toolbar : '#barDemo',
				} ] ],
				page : true
			});

			table.on('rowDouble',function(obj){
			});

			//监听表头工具事件

			table.on('toolbar(video_table)', function(obj) {
				var checkStatus = table.checkStatus(obj.config.id);
				if (obj.event === "xizeng") {
					layer.open({
						type : 2,
						shade : 0.3,
						title : '视频上传',
						btn : [ '提交', '取消' ],
						shadeClose : true,
						anim : 5,
						content : 'coursewarev/vedit',
						area : [ '450px', '500px' ],
						yes : function(index, layero) {
							var obj = layero.find("iframe")[0].contentWindow;
							var win = top.window['layui-layer-iframe' + index];
							var resourceprofile = win.$("#resourceprofile")
									.val(); //获取子窗体数据
							var uuid = win.$("#uuid").val();
							var tbCurriculumid = win.$("#tbCurriculum").val();
							$.post('coursewarev/save1', {
								resourceprofile : resourceprofile,
								uuid : uuid,
								tbCurriculumid:tbCurriculumid
							}, function(msg) {
								layer.msg(msg);
							});
							layer.closeAll('iframe');
						},
						btn2 : function(index, layero) {
							layer.closeAll('iframe');
						},
						end:function(){
						table.reload('idTest', {
							  url: 'coursewarev/page1'
							});
						}
					});
				}
			});

			table.on('tool(video_table)', function(obj) {
				var data = obj.data;
				if (obj.event === "details") {
					layer.open({
						type : 2,
						title:"开放班级",
						shade : 0.3,
						shadeClose : true,
						anim : 5,
						content : 'video/details?id=' + data.id,
						area : [ '550px', '330px' ],
						end : function() {
							
						}
					});
				}
				if (obj.event === "delete") {
					layer.confirm('确认删除？', function(index) {
						$.post('coursewarev/del', {
							id : data.id
						}, function(data) {
							layer.msg(data);
							table.reload('idTest', {
								url : 'coursewarev/page1'
							});
						});

					});
				}
			});
		});
	</script>
</body>
</html>